﻿package com.tudou.home.newskin.buttons
{
    import com.tudou.home.newskin.events.*;
    import com.tudou.skin.*;
    import com.tudou.skin.common.button.*;
    import com.tudou.skin.common.events.*;

    public class PlayPauseButton extends BaseButton implements IPlayer
    {
        private var isCompleted:Boolean = false;
        private var overOut:RollOverOutSprite;

        public function PlayPauseButton()
        {
            addStateButton(new PlayMC());
            addStateButton(new PauseMC());
            var _loc_1:* = new DisablePlayMC();
            _loc_1.useHandCursor = false;
            addStateButton(_loc_1);
            overOut = new RollOverOutSprite(this.width, this.height);
            addEventListener(ButtonEvent.CLICK, buttonHlr);
            activeIndex = 2;
            clickContainer = true;
            return;
        }// end function

        public function buffering() : void
        {
            return;
        }// end function

        public function ready() : void
        {
            addRollOverOut(overOut);
            return;
        }// end function

        private function buttonHlr(event:ButtonEvent) : void
        {
            var _loc_2:String = null;
            if (event.clickIndex == 0)
            {
                if (isCompleted)
                {
                    _loc_2 = SkinEvent.REPLAY;
                }
                else
                {
                    _loc_2 = SkinEvent.PLAY;
                }
                dispatchEvent(new SkinEvent(_loc_2));
            }
            else if (event.clickIndex == 1)
            {
                _loc_2 = SkinEvent.PAUSE;
                dispatchEvent(new SkinEvent(_loc_2));
            }
            return;
        }// end function

        public function completed() : void
        {
            activeIndex = 0;
            isCompleted = true;
            return;
        }// end function

        public function playing() : void
        {
            activeIndex = 1;
            isCompleted = false;
            return;
        }// end function

        public function loading() : void
        {
            removeRollOverOut();
            isCompleted = false;
            return;
        }// end function

        public function paused() : void
        {
            activeIndex = 0;
            return;
        }// end function

    }
}
